package drds.binlog.data_object;


import com.google.gson.annotations.SerializedName;
import drds.binlog.common.Authors;
import drds.common.Author;
import lombok.Getter;
import lombok.Setter;

@Author(name = Authors.LI_YANG)
public final class Header extends DataObject
{


    //
    /**
     * 服务端serverId*
     */
    @SerializedName("serverId")
    @Setter
    @Getter
    public long serverId;


    //
    @SerializedName("serverCode")
    @Setter
    @Getter
    public volatile String serverCode;
    //
    @SerializedName("sourceTypeValue")
    @Setter
    @Getter
    public int sourceTypeValue;
    /**
     * binlog/redolog 文件名
     */
    @SerializedName("logFileName")
    @Setter
    @Getter
    public volatile String logFileName;
    //
    /**
     * binlog/redolog 文件的偏移位置
     */
    @SerializedName("logFileOffset")
    @Setter
    @Getter
    public long logFileOffset;
    //
    //
    @SerializedName("eventTypeValue")
    @Setter
    @Getter
    public int eventTypeValue;
    /**
     * 当前事务的gitd
     */
    @SerializedName("gtid")
    @Setter
    @Getter
    public volatile String gtid;
    /**
     * 变更数据的执行时间
     */
    @SerializedName("executeDateTimeLong")
    @Setter
    @Getter
    public long executeDateTimeLong;
    //
    /**
     * 变更数据的schemaname
     */
    @SerializedName("schemaName")
    @Setter
    @Getter
    public volatile String schemaName;


    //
    /**
     * 变更数据的tablename
     */
    @SerializedName("tableName")
    @Setter
    @Getter
    public volatile String tableName;


    //
    /**
     * <pre>
     * *每个event的长度*
     * </pre>
     */
    @SerializedName("eventLength")
    @Setter
    @Getter
    public long eventLength;
    //
    //
    @SerializedName("propertyList")
    @Setter
    @Getter
    public java.util.List<KeyValuePair> propertyList = java.util.Collections.emptyList();
    //
    @SerializedName("version")
    @Setter
    @Getter
    private int version;
    //
    @SerializedName("eventType")
    @Setter
    @Getter
    private EventType eventType;


    public Header()
    {
        logFileName = "";
        logFileOffset = 0L;

        serverId = 0L;
        serverCode = "";
        executeDateTimeLong = 0L;
        schemaName = "";
        tableName = "";
        eventLength = 0L;

        gtid = "";
    }


    public EventType getEventType()
    {
        @SuppressWarnings("deprecation")
        EventType result = EventType.valueOf(eventTypeValue);
        return result == null ? EventType.unrecognized : result;
    }


}
